<?php
/**
 * Nweb Editor
 *
 * This script is protected by copyright. Its use, copying, modification
 * and distribution without written consent of the author is prohibited.
 *
 * @category    source
 * @package     pl.nweb.editor.model
 * @subpackage  row
 * @author      Krzysztof Kardasz <krzysztof.kardasz@gmail.com>
 * @copyright   Copyright (c) 2012 Krzysztof Kardasz
 * @license     http://www.gnu.org/licenses/lgpl-3.0.txt  GNU Lesser General Public
 * @version     1.0 $Id$
 * @link        https://nweb-editor.googlecode.com
 * @link        http://editor.nweb.pl
 */

namespace pl\nweb\editor\app\model\gateway\row;

use \pl\nweb\editor\app\model\gateway\table\Settings as Table;

/**
 * Model wiersza tabeli
 *
 * @category    source
 * @package     pl.nweb.editor.model
 * @subpackage  row
 * @author      Krzysztof Kardasz <krzysztof.kardasz@gmail.com>
 * @copyright   Copyright (c) 2012 Krzysztof Kardasz
 * @version     1.0 $Id$
 */
class Settings extends \pl\nweb\editor\app\model\gateway\Row
{
    /**
     * Definiuje sekcja
     *
     * @param  string $section sekcja
     * @return void
     */
    public function setSection ($section)
    {
        $this->{Table::FIELD_SECTION} = $section;
    }

    /**
     * Zwraca sekcja
     *
     * @return string
     */
    public function getSection ()
    {
        return $this->get(Table::FIELD_SECTION);
    }

    /**
     * Definiuje nazwę
     *
     * @param  string $name nazwa
     * @return void
     */
    public function setName ($name)
    {
        $this->{Table::FIELD_NAME} = $name;
    }

    /**
     * Zwraca nazwę
     *
     * @return string
     */
    public function getName ()
    {
        return $this->get(Table::FIELD_NAME);
    }

    /**
     * Definiuje 2-znakowy kod języka
     *
     * @param  string $language 2-znakowy kod języka
     * @return void
     */
    public function setLanguage ($language)
    {
        $this->{Table::FIELD_LANGUAGE} = $language;
    }

    /**
     * Zwraca 2-znakowy kod języka
     *
     * @return string
     */
    public function getLanguage ()
    {
        return $this->get(Table::FIELD_LANGUAGE);
    }

    /**
     * Definiuje klasę obiektu
     *
     * @param  string $class klasa obiektu
     * @return void
     */
    public function setClass ($class)
    {
        $this->{Table::FIELD_CLASS} = $class;
    }

    /**
     * Zwraca klasę obiektu
     *
     * @return string
     */
    public function getClass ()
    {
        return $this->get(Table::FIELD_CLASS);
    }

    /**
     * Zwraca dane
     *
     * @return string
     */
    public function getData ()
    {
        return $this->get(Table::FIELD_DATA);
    }

    /**
     * Definiuje klasę
     *
     * @param  string $class klasa
     * @return void
     */
    public function setClass ($class)
    {
        $this->{Table::FIELD_CLASS} = $class;
    }

    /**
     * Zwraca datę utworzenia obiektu
     *
     * @param  string $format format
     * @return null|string
     */
    public function getCreated ($format = 'Y/m/d H:i:s')
    {
        return $this->_getDate(Table::FIELD_CREATED, $format);
    }

    /**
     * Zwraca datę modyfikacji obiektu
     *
     * @param  string $format format
     * @return null|string
     */
    public function getModified ($format = 'Y/m/d H:i:s')
    {
        return $this->_getDate(Table::FIELD_MODIFIED, $format);
    }

    /**
     * Allows pre-update logic to be applied to row.
     * Subclasses may override this method.
     *
     * @return void
     */
    protected function _update()
    {
        $this->{Table::FIELD_MODIFIED} = new \Zend_Db_Expr('NOW()');
    }

    /**
     * Allows pre-insert logic to be applied to row.
     * Subclasses may override this method.
     *
     * @return void
     */
    protected function _insert()
    {
        $this->{Table::FIELD_CREATED} = new \Zend_Db_Expr('NOW()');
        $this->{Table::FIELD_MODIFIED} = new \Zend_Db_Expr('NOW()');
    }
}